<?
//设置需要搜索的表格的前缀后缀
$table_suffix = $sys_term_table;
$table        = $table_Prefix . $table_suffix;
$sort_by      = "nid";
$sort_order   = "desc";
//设置需要搜索的表格的排序项和升降项
?>



<?php

$query = mysql_query("SELECT COUNT(nid) FROM $table where interm = 'root' ");
$sum = mysql_result($query, 0);



$nowpageid=1;
$term0num=5;//每页显示多少个产品


if ($_REQUEST ['nowpageid'])
{
$nowpageid = addslashes($_REQUEST ['nowpageid']);
}
else
{$nowpageid =1;}



//计算一下结果，从那条数据开始显示
$term0start=($nowpageid-1)*$term0num;





if($sum)
{
	
if ($sum < $term0num)
{$page_count=1;
 $term0num=$sum;

}//如果总数据量小于$Pagenum,（pagenum作为每页显示数据的条数，）那么只有一页,而pagenum也更改为sum 


else if($sum % $term0num)
{$page_count = (int) ($sum / $term0num) + 1;}
//取总数据量除以每页数的余数 
//如果有余数，则页数等于总数据量除以每页数的结果取整再加一


else
{$page_count = $sum / $term0num ;}//如果没有余数，则页数等于总数据量除以每页数的结果 

}

else
{$page_count = 0;}


$lastpage=$page_count;
 

$prepage=$nowpageid-1;
$nextpage=$nowpageid+1;


if ($nowpageid==1)
{$prepage=1;}

if ($nowpageid==$page_count )//当现在的页数，就是最后一页的时候。就是说:数据不足一页 或者 到达最后一页
{
	
	if($sum<=$term0num)//总数数据少于每页显示数目，就把循环改成总数数目
   {$term0num=$sum;
   $nextpage=$nowpageid;}
   
   else
	{
	$nextpage=$nowpageid;
 $term0num=fmod($sum,$term0num);
 }//如果现在页数等于总页数（总页数上面求出，最后一页不够循环数的时候），那么最后一页的term0num就会等于余下数据(不足一页)的数目.
  


}

?>



<?
 
 

if ($_REQUEST ['sortby'])
{
$sort_by = addslashes($_REQUEST ['sortby']);
}


$result = mysql_query("select * from $table where interm='root' ORDER BY $sort_by limit $term0start , $term0num");

while($row = mysql_fetch_array($result))
  {
  $term0_nid[]=$row['nid'];
  $term0_mid[]=$row['mid'];
  $term0_name[]=$row['name'];
  $term0_title[]=$row['title'];
  $term0_keyword[]=$row['keyword'];
  $term0_description[]=$row['description'];
  $term0_model[]=$row['model'];
  $term0_introduce[]=$row['introduce'];
  $term0_detail[]=$row['detail'];
  $term0_stock[]=$row['stock'];
  $term0_price[]=$row['price'];
  $term0_memberprice[]=$row['memberprice'];
  $term0_discountprice[]=$row['discountprice'];
  $term0_local[]=$row['local'];
 
  $term0_hotsale[]=$row['hotsale'];
  $term0_discount[]=$row['discount'];
  $term0_recommend[]=$row['recommend'];
  $term0_soldout[]=$row['soldout'];
  $term0_publish[]=$row['publish'];
  $term0_clickrate[]=$row['clickrate'];
  $term0_onsaletime[]=$row['onsaletime'];
  $term0_inputtime[]=$row['inputtime'];
  $term0_modifytime[]=$row['modifytime'];
  $term0_icon[]=$row['icon'];
  $term0_term_banner[]=$row['term_banner'];
  
  $term0_listorder[]=$row['listorder'];
  $term0_markorder[]=$row['markorder'];
  $term0_mark[]=$row['mark'];
  
  $term0_link[]=$row['link'];

}
mysql_close($con);
?>








